define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {

		function get_data_goods_search(result) {
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "","result": {"goods": [' +
					'{"goods_id": 1,"name": "螺丝刀","bn": "新品","store": 100,"price": 10.55,"buy_count": 20,"uptime": "2017/01/01 09:00:00","store_id": 1,"image_default": "img/upload/pro-img01.jpg","freez": 10,"is_tui": true,"is_new": true},' +
					'{"goods_id": 2,"name": "螺丝刀","bn": "热卖","store": 100,"price": 11.55,"buy_count": 20,"uptime": "2017/01/01 09:00:00","store_id": 2,"image_default": "img/upload/pro-img01.jpg","freez": 10,"is_tui": true,"is_new": false}]},' +
					'"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}

		};
		//返回信息
		return {
			//获取首页数据
			goods_search: function(key, orderby, filter, callback) {
				Http.post({
					method: 'goods.insales.search',
					key: key,
					picSize: 'CS',
					orderby: orderby,
					filter: filter
				}, function(result) {
					if(callback)
						callback(get_data_goods_search(result).result);
				}, function(e) {

				}, function() {

				})
			},
			goods_update: function(goods_id, marketable, callback) {
				Http.post({
					method: 'goods.marketable.update',
					session: '',
					goods_id: goods_id,
					marketable: marketable
				}, function(result) {

				}, function(e) {

				}, function() {

				})
			},
			goods_delete: function(goods_id, callback) {
				Http.post({
					method: 'goods.goods.delete',
					session: '',
					goods_id: goods_id
				}, function(result) {

				}, function(e) {

				}, function() {

				})
			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Productmanager_waitsale", factory);
});